import base from './base';
import services from '@/axios';

const chatAPI = {
    //通过便签建立临时会话
    setChat(data) {
        return services({
          headers: {
            'Content-Type': 'multipart/form-data; boundary=something'
          },
          method: 'post',
          url: `${base.test}/privateChat/add`,
          data: data
        })
    },

    //建立群聊
    setGroup(data){
      return services({
        headers: {
          'Content-Type': 'multipart/form-data; boundary=something'
        },
        method: 'post',
        url: `${base.test}/subscriber`,
        data: data
      })
    },

    //获取个人临时消息列表
    getTemporaryMsg(){
        return services.get(`${base.test}/privateChat`)
    },

    //获取个人好友列表
    getFriends(){
        return services.get(`${base.test}/contacts/my`)
    },

    //获取个人所有群聊
    getPersonalGroup(){
      return services.get(`${base.test}/subscriber/allGroups`)
    },

    //获取1v1中另一个成员
    getNoteUser(noteId){
      return services.get(`${base.test}/privateChat/theOther`, {params: {noteId}})
    },

    //获取群组中其他成员
    getGroupUsers(noteId){
      return services.get(`${base.test}/subscriber/all`, {params: {noteId}})
    },

    //发送消息条数(noteId, messageCount)
    sendMessageNumber(data){
      return services({
        headers: {
          'Content-Type': 'multipart/form-data; boundary=something'
        },
        method: 'post',
        url: `${base.test}/privateChat/messageCount`,
        data: data
      })
    },

    //1v1建立好友关系(同意)
    setFriend(data){
      return services({
        headers: {
          'Content-Type': 'multipart/form-data; boundary=something'
        },
        method: 'post',
        url: `${base.test}/privateChat/friends`,
        data: data
      })
    },

    //1v1建立好友关系(拒绝)
    refuseFriend(data){
      return services({
        headers: {
          'Content-Type': 'multipart/form-data; boundary=something'
        },
        method: 'delete',
        url: `${base.test}/privateChat/exit`,
        data: data
      })
    },

    //退出群组
    exitGroup(data){
      return services({
        headers: {
          'Content-Type': 'multipart/form-data; boundary=something'
        },
        method: 'delete',
        url: `${base.test}/subscriber`,
        data: data
      })
    },

    //踢出群组
    kickGroup(data){
      return services({
        headers: {
          'Content-Type': 'multipart/form-data; boundary=something'
        },
        method: 'delete',
        url: `${base.test}/subscriber/kick`,
        data: data
      })
    },

    //群聊添加好友(friendId)
    groupAddFriend(data){
      return services({
        headers: {
          'Content-Type': 'multipart/form-data; boundary=something'
        },
        method: 'post',
        url: `${base.test}/contacts/add`,
        data: data
      })
    },

    //群聊添加好友(friendId)同意拒绝
    groupAddFriend_deal(data){
      return services({
        headers: {
          'Content-Type': 'multipart/form-data; boundary=something'
        },
        method: 'post',
        url: `${base.test}/contacts/accept`,
        data: data
      })
    }
}

export default chatAPI;